package demo3;

import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        ArrayList<ArrayList<Integer>> arrayList = new ArrayList<>();
        ArrayList<Integer> arr1 = new ArrayList<>();
        arr1.add(1);
        arrayList.add(arr1);
        System.out.println(arrayList);
        for (int i = 1; i < 10; i++) {
            ArrayList<Integer> curList = new ArrayList<>();
            curList.add(1);//第一列
            for (int j = 1; j < i; j++) {
                ArrayList<Integer> prevList = arrayList.get(i-1);  //前一行
                int add = prevList.get(j) + prevList.get(j-1);
                curList.add(add);
            }
            curList.add(1);//最后一列
            arrayList.add(curList);
           // System.out.println(arrayList);
            List<String> list = new ArrayList<>();

        }
        for (int i = 0; i < arrayList.size(); i++) {
            ArrayList<Integer> temp = arrayList.get(i);
            for (int j = 0; j < temp.size(); j++) {
                System.out.print(temp.get(j) + " ");
            }
            System.out.println();
        }

    }
}
